
xmlHttpheadercart = false;
xmlHttpdel = false;
	   function create_cart(){
		try {xmlHttpheadercart = new XMLHttpRequest();}catch (trymicrosoft) 
			{
			try {xmlHttpheadercart = new ActiveXObject("Msxml2.XMLHTTP");}catch (othermicrosoft)
				 {
				try {xmlHttpheadercart = new ActiveXObject("Microsoft.XMLHTTP");} catch (failed) 
					{
						xmlHttpheadercart = false;
					}
				}
			}
		if (!xmlHttpheadercart)
		{
			alert('无法创建 XMLHttpRequest 对象!');
		}
	}
	   function del_cart(){
		try {xmlHttpdel = new XMLHttpRequest();}catch (trymicrosoft) 
			{
			try {xmlHttpdel = new ActiveXObject("Msxml2.XMLHTTP");}catch (othermicrosoft)
				 {
				try {xmlHttpdel = new ActiveXObject("Microsoft.XMLHTTP");} catch (failed) 
					{
						xmlHttpdel = false;
					}
				}
			}
		if (!xmlHttpdel)
		{
			alert('无法创建 XMLHttpRequest 对象!');
		}
	}

		//ajax读取购物车信息
	 function cartheader(){
		create_cart();
		xmlHttpheadercart.open("GET","/include/cartheader.php?r="+Math.random(),true);
		xmlHttpheadercart.setRequestHeader("If-Modified-Since","0");
	    xmlHttpheadercart.setRequestHeader("cache-control","nocache"); 
  		

		xmlHttpheadercart.onreadystatechange=function(){
		   if(xmlHttpheadercart.readyState==4&&xmlHttpheadercart.status==200){   
			  
			   str=xmlHttpheadercart.responseText; 
			   
			   var s=str.split("|");
			   document.getElementById('divcart').innerHTML=s[0]; 
			  
			   if(s[1]!=0){ 
			   	document.getElementById('cart_ts').innerHTML=s[1];
				
				$("#cart_ts").show();   
			   }else{	
				$("#cart_ts").hide();   
			   }
			}   
			} 
		
		xmlHttpheadercart.send(null);
		
	 } 
	 
	 //删除购物
	 function delcart(prono){
		del_cart();
		xmlHttpdel.open("GET","/addtocart.htm?A=Remove&prono="+prono,true);
		xmlHttpdel.setRequestHeader("If-Modified-Since","0");
	    xmlHttpdel.setRequestHeader("cache-control","nocache"); 
		
  		xmlHttpdel.onreadystatechange=function(){
		   if(xmlHttpdel.readyState==4&&xmlHttpdel.status==200){   
				cartheader();
			}   
			} 
		xmlHttpdel.send(null);
	 }
	 
